package cn.stylefeng.guns.modular.service.impl;

import cn.stylefeng.guns.base.pojo.page.LayuiPageFactory;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.entity.IdjInformation;
import cn.stylefeng.guns.modular.entity.responseVo.ActivityApplyVo;
import cn.stylefeng.guns.modular.entity.responseVo.InformationVo;
import cn.stylefeng.guns.modular.mapper.IdjInformationMapper;
import cn.stylefeng.guns.modular.service.IIdjInformationService;
import cn.stylefeng.guns.modular.util.json.ArrayUtil;
import cn.stylefeng.roses.core.util.ToolUtil;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.servlet.ModelAndView;

/**
 * <p>
 * 资讯表 服务实现类
 * </p>
 *
 * @author TANGWJ
 * @since 2020-07-30
 */
@Service
public class IdjInformationServiceImpl extends ServiceImpl<IdjInformationMapper, IdjInformation> implements IIdjInformationService {

	@Autowired
	private IdjInformationMapper mapper;
	
	@Override
	public LayuiPageInfo getList(Page<IdjInformation> page, String keyword, String beginTime, String endTime,
			String yes, String no, Integer status, String orderBy, String order) {
		Page<Map<String,Object>> list = mapper.getList(page, keyword, beginTime, endTime, yes, no, status, orderBy, order);
		return LayuiPageFactory.createPageInfo(list);
	}

	@Override
	public ModelAndView edit(Long informationId) {
		IdjInformation information = mapper.selectByKeyId(informationId);
		if(informationId != null){
			if(ToolUtil.isNotEmpty(information.getContent())){
				information.setLists(ArrayUtil.getListByJSONArray(InformationVo.class, information.getContent()));
			}
		}
		ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("information", information);
        return modelAndView;
	}

	@Override
	public int setStatus(IdjInformation Informatio) {
		return mapper.setStatus(Informatio);
	}

	@Override
	public int insert(IdjInformation Informatio) {
		return mapper.insert(Informatio);
	}

	@Override
	public int delete(Long informationId) {
		return mapper.delete(informationId);
	}

}
